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

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

class C:
    def __init__(self, txt: str):
        self.p: F = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.x: F = None
        self.y: D = None
        self.z: F = None
        self.q: F = None
        self.w: A = None
        self.p: D = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.t: C = None
        self.z: A = None
        self.p: C = None
        self.w: E = None
        self.txt = txt

d = A("d")
h = B("h")
k = C("k")
e = D("e")
c = E("c")
a = F("a")
l = E("l")

d.p = a
h.t = k
h.x = k
k.p = a
e.o = d
c.x = a
c.z = a
c.q = a
c.y = e
c.p = e
c.w = d
a.t = k
a.p = k
a.z = d
a.w = l
l.x = a
l.z = a
l.q = a
l.y = e
l.p = e
l.w = d
assert d.p.w.x.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: F = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.p: F = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.x: F = None
        self.y: D = None
        self.z: F = None
        self.q: F = None
        self.w: A = None
        self.p: D = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.t: C = None
        self.z: A = None
        self.p: C = None
        self.w: E = None
        self.txt = txt

d = A("d")
h = B("h")
k = C("k")
e = D("e")
c = E("c")
a = F("a")
l = E("l")

d.p = a
h.t = k
h.x = k
k.p = a
e.o = d
c.x = a
c.z = a
c.q = a
c.y = e
c.p = e
c.w = d
a.t = k
a.p = k
a.z = d
a.w = l
l.x = a
l.z = a
l.q = a
l.y = e
l.p = e
l.w = d
assert d.p.w.x.p.p.txt == "a"