class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.t: B = None
        self.txt = txt

h = A("h")
c = B("c")
n = B("n")
g = A("g")
b = B("b")
j = B("j")

h.w = n
c.t = n
n.t = c
g.w = j
b.t = n
j.t = b
assert c.t.t.t.t.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.t: B = None
        self.txt = txt

h = A("h")
c = B("c")
n = B("n")
g = A("g")
b = B("b")
j = B("j")

h.w = n
c.t = n
n.t = c
g.w = j
b.t = n
j.t = b
assert c.t.t.t.t.t.t.txt == "c"