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

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

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

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

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

class F:
    def __init__(self, txt: str):
        self.q: A = None
        self.x: B = None
        self.u: D = None
        self.v: C = None
        self.z: D = None
        self.txt = txt

g = A("g")
e = B("e")
d = C("d")
j = D("j")
m = E("m")
c = F("c")

g.v = d
g.z = j
e.w = c
d.o = g
j.o = c
m.o = j
c.q = g
c.x = e
c.u = j
c.z = j
c.v = d
assert j.o.v.o.v.o.txt == "
class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.z: D = None
        self.txt = txt

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

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

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

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

class F:
    def __init__(self, txt: str):
        self.q: A = None
        self.x: B = None
        self.u: D = None
        self.v: C = None
        self.z: D = None
        self.txt = txt

g = A("g")
e = B("e")
d = C("d")
j = D("j")
m = E("m")
c = F("c")

g.v = d
g.z = j
e.w = c
d.o = g
j.o = c
m.o = j
c.q = g
c.x = e
c.u = j
c.z = j
c.v = d
assert j.o.v.o.v.o.txt == "g"