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

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

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

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

g = A("g")
d = B("d")
i = C("i")
e = D("e")
m = A("m")
f = B("f")
c = B("c")

g.r = m
g.y = m
g.w = m
g.s = i
d.w = i
i.v = e
e.t = f
m.r = g
m.y = g
m.w = g
m.s = i
f.w = i
c.w = i
assert c.w.v.t.txt == "
class A:
    def __init__(self, txt: str):
        self.r: A = None
        self.s: C = None
        self.y: A = None
        self.w: A = None
        self.txt = txt

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

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

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

g = A("g")
d = B("d")
i = C("i")
e = D("e")
m = A("m")
f = B("f")
c = B("c")

g.r = m
g.y = m
g.w = m
g.s = i
d.w = i
i.v = e
e.t = f
m.r = g
m.y = g
m.w = g
m.s = i
f.w = i
c.w = i
assert c.w.v.t.txt == "f"