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

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

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

g.x = j
g.y = b
j.u = g
j.t = h
b.u = k
b.t = h
c.u = k
c.t = j
h.u = k
h.t = c
k.x = h
k.y = h
assert c.t.u.x.u.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.y: B = None
        self.txt = txt

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

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

g.x = j
g.y = b
j.u = g
j.t = h
b.u = k
b.t = h
c.u = k
c.t = j
h.u = k
h.t = c
k.x = h
k.y = h
assert c.t.u.x.u.txt == "g"