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

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

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

class D:
    def __init__(self, txt: str):
        self.x: C = None
        self.u: D = None
        self.txt = txt

a = A("a")
b = B("b")
n = C("n")
l = D("l")
m = D("m")
e = B("e")

a.y = n
b.y = a
b.u = a
b.p = m
b.t = m
n.q = a
l.x = n
l.u = m
m.x = n
m.u = l
e.y = a
e.u = a
e.p = l
e.t = l
assert e.u.y.q.y.q.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.x: C = None
        self.u: D = None
        self.txt = txt

a = A("a")
b = B("b")
n = C("n")
l = D("l")
m = D("m")
e = B("e")

a.y = n
b.y = a
b.u = a
b.p = m
b.t = m
n.q = a
l.x = n
l.u = m
m.x = n
m.u = l
e.y = a
e.u = a
e.p = l
e.t = l
assert e.u.y.q.y.q.txt == "a"