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

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

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

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

e = A("e")
j = B("j")
a = C("a")
c = D("c")

e.o = c
e.s = c
j.p = e
j.s = a
a.q = c
c.x = e
c.r = a
c.w = a
assert e.o.x.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: D = None
        self.s: D = None
        self.txt = txt

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

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

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

e = A("e")
j = B("j")
a = C("a")
c = D("c")

e.o = c
e.s = c
j.p = e
j.s = a
a.q = c
c.x = e
c.r = a
c.w = a
assert e.o.x.o.txt == "c"