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

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

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

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

i = A("i")
e = B("e")
j = C("j")
g = D("g")

i.y = j
e.x = j
e.q = j
e.o = i
j.y = i
g.p = j
g.t = j
assert g.p.y.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.txt = txt

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

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

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

i = A("i")
e = B("e")
j = C("j")
g = D("g")

i.y = j
e.x = j
e.q = j
e.o = i
j.y = i
g.p = j
g.t = j
assert g.p.y.y.y.txt == "i"