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

class B:
    def __init__(self, txt: str):
        self.p: C = None
        self.s: C = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.s: E = None
        self.z: B = None
        self.p: F = None
        self.x: F = None
        self.q: A = None
        self.r: A = None
        self.txt = txt

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

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

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

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

e.r = h
e.v = g
g.p = c
g.s = c
c.s = m
c.z = g
c.p = h
c.x = h
c.q = e
c.r = e
f.o = c
f.v = g
m.q = h
m.p = h
m.t = f
h.t = m
assert c.s.t.o.x.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.r: F = None
        self.v: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.p: C = None
        self.s: C = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.s: E = None
        self.z: B = None
        self.p: F = None
        self.x: F = None
        self.q: A = None
        self.r: A = None
        self.txt = txt

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

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

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

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

e.r = h
e.v = g
g.p = c
g.s = c
c.s = m
c.z = g
c.p = h
c.x = h
c.q = e
c.r = e
f.o = c
f.v = g
m.q = h
m.p = h
m.t = f
h.t = m
assert c.s.t.o.x.t.t.txt == "f"