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

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

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

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

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

i.w = h
i.y = h
i.p = j
j.x = k
j.t = k
h.o = c
h.r = j
h.x = i
c.q = j
f.q = j
k.o = c
k.r = j
k.x = i
assert i.p.t.x.p.x.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.p: B = None
        self.y: C = None
        self.txt = txt

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

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

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

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

i.w = h
i.y = h
i.p = j
j.x = k
j.t = k
h.o = c
h.r = j
h.x = i
c.q = j
f.q = j
k.o = c
k.r = j
k.x = i
assert i.p.t.x.p.x.txt == "k"