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

class B:
    def __init__(self, txt: str):
        self.y: C = None
        self.w: F = None
        self.txt = txt

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

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

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

class F:
    def __init__(self, txt: str):
        self.x: E = None
        self.z: C = None
        self.t: C = None
        self.v: A = None
        self.o: E = None
        self.txt = txt

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

c.r = g
c.p = g
c.u = b
g.y = l
g.w = n
l.w = c
l.u = g
b.w = g
b.o = g
e.r = l
e.q = c
n.x = e
n.o = e
n.z = l
n.t = l
n.v = c
assert g.y.w.r.w.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.u: D = None
        self.p: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.y: C = None
        self.w: F = None
        self.txt = txt

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

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

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

class F:
    def __init__(self, txt: str):
        self.x: E = None
        self.z: C = None
        self.t: C = None
        self.v: A = None
        self.o: E = None
        self.txt = txt

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

c.r = g
c.p = g
c.u = b
g.y = l
g.w = n
l.w = c
l.u = g
b.w = g
b.o = g
e.r = l
e.q = c
n.x = e
n.o = e
n.z = l
n.t = l
n.v = c
assert g.y.w.r.w.txt == "n"