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

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

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

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

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

class F:
    def __init__(self, txt: str):
        self.o: C = None
        self.t: D = None
        self.txt = txt

c = A("c")
j = B("j")
n = C("n")
d = D("d")
b = E("b")
g = F("g")

c.r = j
c.o = n
c.p = b
j.o = d
j.u = b
j.s = b
n.r = b
n.y = c
n.w = g
d.r = n
b.z = c
b.q = j
b.v = d
g.o = n
g.t = d
assert n.y.r.s.z.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.o: C = None
        self.p: E = None
        self.txt = txt

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

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

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

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

class F:
    def __init__(self, txt: str):
        self.o: C = None
        self.t: D = None
        self.txt = txt

c = A("c")
j = B("j")
n = C("n")
d = D("d")
b = E("b")
g = F("g")

c.r = j
c.o = n
c.p = b
j.o = d
j.u = b
j.s = b
n.r = b
n.y = c
n.w = g
d.r = n
b.z = c
b.q = j
b.v = d
g.o = n
g.t = d
assert n.y.r.s.z.txt == "c"