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

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

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

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

l = A("l")
g = B("g")
c = C("c")
i = D("i")
a = A("a")

l.y = i
g.t = a
c.r = g
i.r = g
i.w = a
a.y = i
assert c.r.t.y.w.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: D = None
        self.txt = txt

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

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

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

l = A("l")
g = B("g")
c = C("c")
i = D("i")
a = A("a")

l.y = i
g.t = a
c.r = g
i.r = g
i.w = a
a.y = i
assert c.r.t.y.w.y.txt == "i"