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

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

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

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

f = A("f")
k = B("k")
b = C("b")
i = D("i")
c = C("c")
m = C("m")
d = B("d")
j = B("j")
g = C("g")

f.r = m
f.q = m
f.p = g
k.y = f
k.w = b
k.q = d
b.x = k
i.w = g
i.v = f
c.x = d
m.x = j
d.y = f
d.w = m
d.q = j
j.y = f
j.w = m
j.q = k
g.x = j
assert k.y.p.x.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.q: C = None
        self.p: C = None
        self.txt = txt

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

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

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

f = A("f")
k = B("k")
b = C("b")
i = D("i")
c = C("c")
m = C("m")
d = B("d")
j = B("j")
g = C("g")

f.r = m
f.q = m
f.p = g
k.y = f
k.w = b
k.q = d
b.x = k
i.w = g
i.v = f
c.x = d
m.x = j
d.y = f
d.w = m
d.q = j
j.y = f
j.w = m
j.q = k
g.x = j
assert k.y.p.x.txt == "j"