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

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

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

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

e = A("e")
m = B("m")
c = C("c")
h = D("h")

e.t = c
m.o = c
m.q = c
c.x = h
h.v = e
h.o = m
h.p = m
h.x = m
assert e.t.x.p.txt == "
class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.txt = txt

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

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

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

e = A("e")
m = B("m")
c = C("c")
h = D("h")

e.t = c
m.o = c
m.q = c
c.x = h
h.v = e
h.o = m
h.p = m
h.x = m
assert e.t.x.p.txt == "m"