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

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

b = A("b")
c = B("c")
f = B("f")
l = A("l")
g = B("g")
h = B("h")
d = B("d")
n = A("n")

b.t = l
c.y = n
c.x = g
f.y = n
f.x = d
l.t = n
g.y = l
g.x = h
h.y = n
h.x = g
d.y = n
d.x = c
n.t = b
assert c.x.y.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.t: A = None
        self.txt = txt

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

b = A("b")
c = B("c")
f = B("f")
l = A("l")
g = B("g")
h = B("h")
d = B("d")
n = A("n")

b.t = l
c.y = n
c.x = g
f.y = n
f.x = d
l.t = n
g.y = l
g.x = h
h.y = n
h.x = g
d.y = n
d.x = c
n.t = b
assert c.x.y.t.t.txt == "b"