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

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

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

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

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

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

m = A("m")
a = B("a")
j = C("j")
h = D("h")
l = E("l")
d = F("d")
k = A("k")

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

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

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

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

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

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

m = A("m")
a = B("a")
j = C("j")
h = D("h")
l = E("l")
d = F("d")
k = A("k")

m.r = h
a.x = d
a.o = h
j.v = h
j.x = d
j.z = l
j.q = l
h.r = k
h.z = k
h.o = j
l.w = j
d.v = j
d.z = h
k.r = h
assert d.v.v.z.r.o.txt == "j"