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.o: B = None
        self.txt = txt

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

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

c = A("c")
i = B("i")
f = C("f")
g = D("g")
j = B("j")

c.t = i
c.q = f
i.o = j
f.y = i
f.r = c
g.y = c
g.w = f
j.o = i
assert g.w.r.q.r.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.o: B = None
        self.txt = txt

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

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

c = A("c")
i = B("i")
f = C("f")
g = D("g")
j = B("j")

c.t = i
c.q = f
i.o = j
f.y = i
f.r = c
g.y = c
g.w = f
j.o = i
assert g.w.r.q.r.t.txt == "i"