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

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

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

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

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

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

m = A("m")
a = B("a")
j = C("j")
d = D("d")
b = E("b")
h = F("h")
c = B("c")

m.o = d
a.x = j
a.q = h
a.t = b
a.o = d
j.q = d
d.r = h
b.p = m
b.t = a
b.w = j
b.z = h
b.s = d
h.v = a
h.o = d
c.x = j
c.q = h
c.t = b
c.o = d
assert h.o.r.v.o.r.v.txt == "
class A:
    def __init__(self, txt: str):
        self.o: D = None
        self.txt = txt

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

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

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

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

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

m = A("m")
a = B("a")
j = C("j")
d = D("d")
b = E("b")
h = F("h")
c = B("c")

m.o = d
a.x = j
a.q = h
a.t = b
a.o = d
j.q = d
d.r = h
b.p = m
b.t = a
b.w = j
b.z = h
b.s = d
h.v = a
h.o = d
c.x = j
c.q = h
c.t = b
c.o = d
assert h.o.r.v.o.r.v.txt == "a"