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

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

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

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

c = A("c")
e = B("e")
a = C("a")
f = D("f")
h = D("h")
l = A("l")
m = B("m")

c.p = m
c.w = h
c.x = a
e.t = c
e.s = m
a.z = e
a.u = l
a.p = l
a.q = c
f.q = l
f.y = l
f.p = h
h.q = l
h.y = c
h.p = f
l.p = m
l.w = f
l.x = a
m.t = l
m.s = e
assert m.t.p.t.p.t.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.w: D = None
        self.x: C = None
        self.txt = txt

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

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

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

c = A("c")
e = B("e")
a = C("a")
f = D("f")
h = D("h")
l = A("l")
m = B("m")

c.p = m
c.w = h
c.x = a
e.t = c
e.s = m
a.z = e
a.u = l
a.p = l
a.q = c
f.q = l
f.y = l
f.p = h
h.q = l
h.y = c
h.p = f
l.p = m
l.w = f
l.x = a
m.t = l
m.s = e
assert m.t.p.t.p.t.txt == "l"