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

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

class C:
    def __init__(self, txt: str):
        self.w: E = None
        self.r: D = None
        self.x: D = None
        self.s: F = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.s: A = None
        self.r: D = None
        self.y: A = None
        self.t: C = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.y: E = None
        self.u: D = None
        self.q: D = None
        self.x: D = None
        self.t: C = None
        self.txt = txt

d = A("d")
e = B("e")
n = C("n")
b = D("b")
c = E("c")
l = F("l")

d.p = l
e.t = c
e.p = c
e.z = c
e.q = d
e.x = b
n.w = c
n.r = b
n.x = b
n.s = l
b.z = d
b.u = e
b.p = e
c.s = d
c.y = d
c.r = b
c.t = n
l.y = c
l.u = b
l.q = b
l.x = b
l.t = n
assert d.p.q.z.p.q.txt == "
class A:
    def __init__(self, txt: str):
        self.p: F = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.w: E = None
        self.r: D = None
        self.x: D = None
        self.s: F = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.s: A = None
        self.r: D = None
        self.y: A = None
        self.t: C = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.y: E = None
        self.u: D = None
        self.q: D = None
        self.x: D = None
        self.t: C = None
        self.txt = txt

d = A("d")
e = B("e")
n = C("n")
b = D("b")
c = E("c")
l = F("l")

d.p = l
e.t = c
e.p = c
e.z = c
e.q = d
e.x = b
n.w = c
n.r = b
n.x = b
n.s = l
b.z = d
b.u = e
b.p = e
c.s = d
c.y = d
c.r = b
c.t = n
l.y = c
l.u = b
l.q = b
l.x = b
l.t = n
assert d.p.q.z.p.q.txt == "b"