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

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

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

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

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

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

e = A("e")
j = B("j")
m = C("m")
b = D("b")
g = E("g")
h = F("h")
f = D("f")

e.x = m
e.q = g
j.x = b
j.v = e
m.r = h
b.x = h
g.t = f
h.s = m
h.z = g
f.x = h
assert m.r.z.t.x.z.t.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.q: E = None
        self.txt = txt

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

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

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

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

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

e = A("e")
j = B("j")
m = C("m")
b = D("b")
g = E("g")
h = F("h")
f = D("f")

e.x = m
e.q = g
j.x = b
j.v = e
m.r = h
b.x = h
g.t = f
h.s = m
h.z = g
f.x = h
assert m.r.z.t.x.z.t.txt == "f"