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

class B:
    def __init__(self, txt: str):
        self.y: D = None
        self.w: A = None
        self.p: D = None
        self.t: A = None
        self.txt = txt

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

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

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

b.t = i
b.q = j
i.y = e
i.p = e
i.w = b
i.t = b
j.s = i
j.w = i
j.y = i
e.w = b
assert i.t.t.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.q: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.y: D = None
        self.w: A = None
        self.p: D = None
        self.t: A = None
        self.txt = txt

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

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

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

b.t = i
b.q = j
i.y = e
i.p = e
i.w = b
i.t = b
j.s = i
j.w = i
j.y = i
e.w = b
assert i.t.t.t.t.txt == "i"